package net.chrisrichardson.ec2deployer.cluster

class EbsVolume {
    String volumeId
    String device
    String snapshotId
    Integer size
    
    EbsVolume() {
    }

    static EbsVolume existingVolume(String volumeId, String device) {
        new EbsVolume(volumeId, null, 0, device)
    }

    static EbsVolume newVolume(Integer size, String device) {
        new EbsVolume(null, null, size, device)
    }

    static EbsVolume newVolumeFromSnapshot(String snapshotId, Integer size, String device) {
        new EbsVolume(null, snapshotId, size, device)
    }

    private EbsVolume(String volumeId, String snapshotId, Integer size, String device) {
        this.volumeId = volumeId
        this.snapshotId = snapshotId
        this.size = size;
        this.device = device
    }

    boolean getUseExistingVolume() {
        volumeId
    }

    boolean getMustCreateDb() {
        !volumeId && !snapshotId
    }

}
